//package com.foreveross.project.usercenterserver.security.config;
//
//import com.foreveross.project.usercenterserver.common.constant.CachesEnum;
//import com.github.benmanes.caffeine.cache.Caffeine;
//import org.springframework.cache.CacheManager;
//import org.springframework.cache.annotation.EnableCaching;
//import org.springframework.cache.caffeine.CaffeineCache;
//import org.springframework.cache.support.SimpleCacheManager;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import java.util.ArrayList;
//import java.util.concurrent.TimeUnit;
//
//@Configuration
//@EnableCaching
//public class CaffeineCacheConfiguration {
//
//	@Bean
//	public CacheManager cacheManager() {
//
//		SimpleCacheManager cacheManager = new SimpleCacheManager();
//		ArrayList<CaffeineCache> caches = new ArrayList<CaffeineCache>();
//		for (CachesEnum c : CachesEnum.values()) {
//			caches.add(new CaffeineCache(c.name(), Caffeine.newBuilder().expireAfterWrite(c.getTtl(), TimeUnit.SECONDS)
//					.maximumSize(c.getMaxSize()).build()));
//		}
//		cacheManager.setCaches(caches);
//		return cacheManager;
//	}
//
//}
